Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typeName with tailing whitespace #428

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FL4TLiN3
Copy link

Problem:

While processing parseFqTypeName(), typeName for vector field ( vector<float, x> ) contains tailing whitespace like "org.apache.cassandra.db.marshal.FloatType ".

TypeError: Not a valid type "org.apache.cassandra.db.marshal.FloatType "
 ❯ parseFqTypeName node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/encoder.js:1372:13
 ❯ Encoder.parseVectorTypeArgs node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/encoder.js:994:24
 ❯ Encoder.encodeCustom node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/encoder.js:716:44
 ❯ Encoder.encode node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/encoder.js:1703:18
 ❯ node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/requests.js:458:71
 ❯ BatchRequest.eachQuery node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/requests.js:458:14
 ❯ BatchRequest.write node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/requests.js:440:18
 ❯ WriteQueue.process node_modules/.pnpm/[email protected]/node_modules/cassandra-driver/lib/writers.js:247:44

This problem is caused by Cassandra's prepared statement functionality.
While the driver tries to get columns info from Cassandra, it sends response like;

columns: [
  { name: 'document_id', type: { code: 13, type: null } },
  { name: 'chunk_number', type: { code: 2, type: null } },
  {
    name: 'embedding',
    type: {
      code: 0,
      type: null,
      info: 'org.apache.cassandra.db.marshal.VectorType(org.apache.cassandra.db.marshal.FloatType , 256)'
    }
  },
  { name: 'chunk', type: { code: 13, type: null } },
  { name: 'language', type: { code: 13, type: null } }
]

(Cassandra version 5.0.1)

The string literal "org.apache.cassandra.db.marshal.VectorType(org.apache.cassandra.db.marshal.FloatType , 256)" seems to be valid for type.info, so I believe the driver should trim tailing whitespace in parseFqTypeName().

@FL4TLiN3
Copy link
Author

@FL4TLiN3 FL4TLiN3 changed the title Fix typeName with taling whitespace Fix typeName with tailing whitespace Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant